﻿@model ProductDetailsModel
@using IT.CMS.Core.Domain.Seo;
@using IT.CMS.Core.Infrastructure;
@using IT.CMS.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title, meta
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(productUrl);
    }
}
@{
    var defaultProductVariant = Model.ProductVariantModels.Count > 0 ? Model.ProductVariantModels[0] : null;
}
<!--product breadcrumb-->
@Html.Action("ProductBreadcrumb", "Catalog", new { productId = Model.Id })
<div class="clear">
</div>
<div class="page product-details-page">
    <div class="page-body">
        @Html.Widget("productdetails_top")
        @using (Html.BeginRouteForm("Product", new { SeName = Model.SeName }, FormMethod.Post, new { id = "product-details-form" }))
        {
            <div itemscope itemtype="http://schema.org/Product">
                <div class="product-essential">
                    @Html.Widget("productdetails_before_pictures")
                    <!--product pictures-->
                    @Html.Partial("_ProductDetailsPictures", Model)
                    @Html.Widget("productdetails_after_pictures")
                    <div class="overview">
                        <div class="product-name">
                            <h1 itemprop="name">
                                @Model.Name
                            </h1>
                        </div>
                        @if (!String.IsNullOrEmpty(Model.ShortDescription))
                        {
                            <div class="short-description">
                                @Html.Raw(Model.ShortDescription)
                            </div>
                        }
                        <div class="clear">
                        </div>
                        @Html.Widget("productdetails_overview_top")
                        <!--product SKU, manufacturer part number, stock info-->
                        @Html.Partial("_ProductVariant_SKU_Man_Stock", defaultProductVariant)
                        <div class="clear">
                        </div>
                        <!--Back in stock subscription-->
                        @Html.Partial("_ProductVariantBackInStockSubscription", defaultProductVariant)
                        <div class="clear">
                        </div>
                        <!--product manufacturers-->
                        @Html.Action("ProductManufacturers", "Catalog", new { productId = Model.Id })
                        <div class="clear">
                        </div>
                        <!--product reviews-->
                        @Html.Action("ProductReviewOverview", "Catalog", new { productId = Model.Id })
                        <div class="clear">
                        </div>
                        <!--sample download-->
                        @Html.Partial("_DownloadSample", defaultProductVariant)
                        <div class="clear">
                        </div>
                        @{
                            var dataDictPrice = new ViewDataDictionary();
                            dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", defaultProductVariant.Id);
                            @Html.Partial("_ProductVariantPrice", defaultProductVariant.ProductVariantPrice, dataDictPrice)
                            
                            var dataDictAddToCart = new ViewDataDictionary();
                            dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", defaultProductVariant.Id);
                            @Html.Partial("_ProductVariantAddToCart", defaultProductVariant.AddToCart, dataDictAddToCart)                    
                        }
                        <div class="clear">
                        </div>
                        @Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id })
                        @Html.Action("CompareProductsButton", "Catalog", new { productId = Model.Id })
                        <div class="clear">
                        </div>
                        @Html.Action("ShareButton", "Catalog")
                        @Html.Widget("productdetails_overview_bottom")
                    </div>
                    @if (!String.IsNullOrEmpty(Model.FullDescription))
                    {
                        <div class="full-description" itemprop="description">
                            @Html.Raw(Model.FullDescription)
                        </div>
                    }
                </div>
                <div class="clear">
                </div>
                @Html.Widget("productdetails_before_collateral")
                <div class="product-collateral">
                    <div class="product-variant-line">
                        <!--product tier prices-->
                        @Html.Action("ProductTierPrices", "Catalog", new { productVariantId = defaultProductVariant.Id })
                        <div class="clear">
                        </div>
                        @{
                    var dataDictAttributes = new ViewDataDictionary();
                    dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", defaultProductVariant.Id);
                            @Html.Partial("_ProductAttributes", defaultProductVariant.ProductVariantAttributes, dataDictAttributes)                  
                        }
                        <div class="clear">
                        </div>
                        @{
                    var dataDictGiftCard = new ViewDataDictionary();
                    dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", defaultProductVariant.Id);
                            @Html.Partial("_GiftCardInfo", defaultProductVariant.GiftCard, dataDictGiftCard)
                        }
                    </div>
                    @Html.Action("ProductSpecifications", "Catalog", new { productId = Model.Id })
                    <div class="clear">
                    </div>
                    @Html.Action("ProductTags", "Catalog", new { productId = Model.Id })
                    <div class="clear">
                    </div>
                    @Html.Action("ProductsAlsoPurchased", "Catalog", new { productId = Model.Id })
                    <div class="clear">
                    </div>
                    @Html.Action("RelatedProducts", "Catalog", new { productId = Model.Id })
                    <div class="clear">
                    </div>
                </div>
            </div>
        }
        @Html.Widget("productdetails_bottom")
    </div>
</div>
